#pragma once

#include "fxcc/core/graph/common/Viewport.h"
#include "fxcc/core/graph/common/Frustum.h"

namespace fxcc
{
	namespace graph
	{
		namespace common
		{

			struct FXCC_API  ProjData {

				bool m_IsOrtho{ false };

				float m_HorizontalFOV{45.f};

				float m_ClipPlaneNear{ 0.1f };

				float m_ClipPlaneFar{100.0f};

				float m_Aspect{ 1.0f };

				float m_OrthographicWidth{1200};

				float m_OrthographicHeight{900};

				void LoadAspect() {

					if (m_OrthographicHeight == 0.0f)
					{
						m_Aspect = 1.0f;
					}
					else
					{
						m_Aspect = (float)m_OrthographicWidth / (float)m_OrthographicHeight;
					}
				}
				glm::mat4 GetProjMatrix() const
				{
					if (m_IsOrtho)
					{
						Viewport vp;
						vp.left = -m_OrthographicWidth / 2.0f;
						vp.right = m_OrthographicWidth / 2.0f;


						vp.top = m_OrthographicHeight / 2.0f;
						vp.bottom = -m_OrthographicHeight / 2.0f;

						vp.zNear = m_ClipPlaneNear;
						vp.zFar = m_ClipPlaneFar;

						return vp.GetOrthoMatrix();
					}
					else
					{
						Frustum f;
						f.aspect = m_Aspect;
						f.nFar = m_ClipPlaneFar;
						f.nNear = m_ClipPlaneNear;
						f.fovy = m_HorizontalFOV;
						return f.GetProjection();
					}

				}
			};
		}
	}
}